class Solution {
public:
    string reverseLeftWords(string s, int n) {
        if(s.length() > n){
            reverseString(s, 0, n - 1);
            reverseString(s, n, s.length() - 1);
            reverseString(s, 0, s.length() - 1);
        }

        return s;
    }

    void reverseString(string &s, int form, int to){
        for(int i = 0; i < (to - form + 1) / 2; ++i){
            char temp = s[form + i];
            s[form + i] = s[to - i];
            s[to - i] = temp;
        }
    }
};